package jay.home.bet.web.struts;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jay.home.bet.domain.Event;
import jay.home.bet.misc.Util;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class UpdateBodanAction extends BaseAction {
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception 
	{
		String id = request.getParameter("id");
		Event event = getOddsService().getEventByComp(id);
		
		event.getBodan().setS00(Util.toDouble(request.getParameter("s00")));
		event.getBodan().setS01(Util.toDouble(request.getParameter("s01")));
		event.getBodan().setS02(Util.toDouble(request.getParameter("s02")));
		event.getBodan().setS03(Util.toDouble(request.getParameter("s03")));
		event.getBodan().setS04(Util.toDouble(request.getParameter("s04")));
		event.getBodan().setS10(Util.toDouble(request.getParameter("s10")));
		event.getBodan().setS11(Util.toDouble(request.getParameter("s11")));
		event.getBodan().setS12(Util.toDouble(request.getParameter("s12")));
		event.getBodan().setS13(Util.toDouble(request.getParameter("s13")));
		event.getBodan().setS14(Util.toDouble(request.getParameter("s14")));
		event.getBodan().setS20(Util.toDouble(request.getParameter("s20")));
		event.getBodan().setS21(Util.toDouble(request.getParameter("s21")));
		event.getBodan().setS22(Util.toDouble(request.getParameter("s22")));
		event.getBodan().setS23(Util.toDouble(request.getParameter("s23")));
		event.getBodan().setS24(Util.toDouble(request.getParameter("s24")));
		event.getBodan().setS30(Util.toDouble(request.getParameter("s30")));
		event.getBodan().setS31(Util.toDouble(request.getParameter("s31")));
		event.getBodan().setS32(Util.toDouble(request.getParameter("s32")));
		event.getBodan().setS33(Util.toDouble(request.getParameter("s33")));
		event.getBodan().setS34(Util.toDouble(request.getParameter("s34")));
		event.getBodan().setS40(Util.toDouble(request.getParameter("s40")));
		event.getBodan().setS41(Util.toDouble(request.getParameter("s41")));
		event.getBodan().setS42(Util.toDouble(request.getParameter("s42")));
		event.getBodan().setS43(Util.toDouble(request.getParameter("s43")));
		event.getBodan().setS44(Util.toDouble(request.getParameter("s44")));
		event.getBodan().setSxx(Util.toDouble(request.getParameter("sxx")));
		
		getOddsService().updateEventsByComp(event);
		Map map = getOddsService().getCounter(event.getId());
		
		request.setAttribute("event", event);
		request.setAttribute("map", map);
		return mapping.findForward("SUCCESS");
	}

}
